package com.lc.luzhengtang.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by DR on 2016/9/7.
 */
@HttpInlet(Conn.COMMENT_EVELUTE)
public class GetEvaluate extends BaseAsyGet {
    //用户ID，订单ID
    public String uid, ordersn;

    public GetEvaluate(AsyCallBack asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected EvaluateInfo parser(JSONObject object) throws Exception {

        if (object.optString("status").equals("1")) {

            EvaluateInfo info = new EvaluateInfo();

            JSONArray array = object.optJSONArray("goods");

            if (array != null) {

                for (int i = 0; i < array.length(); i++) {

                    JSONObject o = array.optJSONObject(i);
                    EvaluateList evaluateList = new EvaluateList();

                    evaluateList.gid = o.optString("gid");
                    evaluateList.goodsname = o.optString("goodsname");
                    evaluateList.picurl = o.optString("picurl");
                    evaluateList.price = o.optString("price");

                    info.evaluateList.add(evaluateList);

                }

            }

            return info;

        }

        return null;

    }

    public static class EvaluateInfo {

        public List<EvaluateList> evaluateList = new ArrayList<>();

    }

    public static class EvaluateList {
        //gid，商品名称，图片，数量，价格
        public String gid, goodsname, picurl, num, price, etStr = "";
        public int starExpress = 4,  starSpeed = 4, starQuality = 4;
        public int starDescribe = 4;

    }

}
